
<?php if($session->check('Auth.User')):?>
<div class="actions" align="left">
  <ul>
    <li><?php echo $html->link(__('Saved Ballots', true), array('action'=>'index')); ?></li>
  </ul>
  <p>
</div>
<?php endif;?>

<div class="ballots_form">
<?php echo $form->create('Ballot', array('action' => 'getBallot'));?>
    Enter Zip code to get ballot: 
    <input type="text" id="BallotZip" value="" name="data[Ballot][zip]" size="6" maxlength="6"/>
    -
    <input type="text" id="BallotZip" value="" name="data[Ballot][plus4]" size="4" maxlength="4"/>
    <input type="submit" value="Get Ballot"/>
<?php echo $form->end();?>

</div>

<?php if(!empty($ballotData)):?>
<div class="ballots view">
<h2><?php  __('Sample Ballot');?> for ZIP code: <?php echo $ballotData['zip']?><?php if (!empty($ballotData['plus4'])): echo '-'.$ballotData['plus4']; endif;?><br />
Your voting date is <?php echo $ballotData['voteDate']?><br />
</h2>

<?php echo $html->link(__('Save', true), array('action' => 'save'));?>

<table cellpadding="0" cellspacing="0">
<?php
//print_r($ballotData);
$i = 0;
foreach ($ballotData['elections'] as $election):
$class = null;
if ($i++ % 2 == 0) {
	$class = ' class="altrow"';
}
?>
	<tr>
		<td style="border-bottom: 1px #999999 solid" colspan="2">
		<h2><?php echo $election['name'].' '.$election['stage']?> Election</h2>
		</td>
	</tr>
	<tr>
		<td width="50%" style="border-bottom: 1px #999999 solid">
		<table width="100%" border="0" cellspacing="5" cellpadding="3">
		<?php foreach ($election['offices'] as $office): ?>
			<tr>
				<td width="20%"
					rowspan="<?php echo count($office['candidates']) + 2?>">
				<h3><?php echo $office['Office']?>:</h3>
				</td>
			</tr>
			<tr>
			 <th width="50px"></th>
			 <th>Candidate</th>
			 <th>Party</th>
			</tr>
			<?php foreach ($office['candidates'] as $candidate): ?>
			<tr>
				<td style="border-bottom: 1px #999999 solid">
				  <?php if (isset($candidate['like'])) {
            $attitude = $candidate['like'];
          }
          else {
            $attitude = null;
          }?>
          <?php echo $candidateSelector->makeSelector($candidate['firstName'], $candidate['lastName'], $attitude);?>
				</td>
				<td style="border-bottom: 1px #999999 solid">
				<b><?php 
				  echo $candidate['firstName'];
				  if (strlen($candidate['nickName'] > 0)) {
				    echo ' "'.$candidate['nickName'].'"';
				  }
				  echo ' '.$candidate['middleName'].' '.$candidate['lastName'];
				 ?></b>
				</td>
				<td style="border-bottom: 1px #999999 solid"><span><?php echo $candidate['party']?></span></td>
			</tr>
			<?php endforeach;?>
			<?php endforeach;?>
		</table>
		</td>
	</tr>
	<?php endforeach;?>
</table>
	<?php if (!empty($ballotData['measures'])): ?>
	<hr></hr>
	<h2>Ballot Measures</h2>
	<ul>
	<?php foreach ($ballotData['measures'] as $meas): ?>
		<li>
		<h3><?php echo $meas['code'] ?></h3>
		</li>
		<ul>
			<li><?php echo $meas['title'] ?> <!-- input id="<% $meas->measureCode %>" name="measure-<% $meas->measureTitle %> " type="checkbox"--></li>
		</ul>
		<?php endforeach; ?>
	</ul>
	<?php else: ?>
	<hr>
	<h3>There are no measures on this ballot.</h3>
	<?php endif;?>

</div>
<?php endif;?>
<div class="actions"></div>
